package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Goodscomments;
import com.ruoyi.system.service.IGoodscommentsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商品评论表Controller
 * 
 * @author ruoyi
 * @date 2024-12-25
 */
@RestController
@RequestMapping("/camp/goodscomments")
public class GoodscommentsController extends BaseController
{
    @Autowired
    private IGoodscommentsService goodscommentsService;

    /**
     * 查询商品评论表列表
     */
    @PreAuthorize("@ss.hasPermi('camp:goodscomments:list')")
    @GetMapping("/list")
    public TableDataInfo list(Goodscomments goodscomments)
    {
        startPage();
        List<Goodscomments> list = goodscommentsService.selectGoodscommentsList(goodscomments);
        return getDataTable(list);
    }

    /**
     * 导出商品评论表列表
     */
    @PreAuthorize("@ss.hasPermi('camp:goodscomments:export')")
    @Log(title = "商品评论表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Goodscomments goodscomments)
    {
        List<Goodscomments> list = goodscommentsService.selectGoodscommentsList(goodscomments);
        ExcelUtil<Goodscomments> util = new ExcelUtil<Goodscomments>(Goodscomments.class);
        util.exportExcel(response, list, "商品评论表数据");
    }

    /**
     * 获取商品评论表详细信息
     */
    @PreAuthorize("@ss.hasPermi('camp:goodscomments:query')")
    @GetMapping(value = "/{goodscommentsId}")
    public AjaxResult getInfo(@PathVariable("goodscommentsId") String goodscommentsId)
    {
        return success(goodscommentsService.selectGoodscommentsByGoodscommentsId(goodscommentsId));
    }

    /**
     * 新增商品评论表
     */
    @PreAuthorize("@ss.hasPermi('camp:goodscomments:add')")
    @Log(title = "商品评论表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Goodscomments goodscomments)
    {
        return toAjax(goodscommentsService.insertGoodscomments(goodscomments));
    }

    /**
     * 修改商品评论表
     */
    @PreAuthorize("@ss.hasPermi('camp:goodscomments:edit')")
    @Log(title = "商品评论表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Goodscomments goodscomments)
    {
        return toAjax(goodscommentsService.updateGoodscomments(goodscomments));
    }

    /**
     * 删除商品评论表
     */
    @PreAuthorize("@ss.hasPermi('camp:goodscomments:remove')")
    @Log(title = "商品评论表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{goodscommentsIds}")
    public AjaxResult remove(@PathVariable String[] goodscommentsIds)
    {
        return toAjax(goodscommentsService.deleteGoodscommentsByGoodscommentsIds(goodscommentsIds));
    }
}
